#!/bin/bash

echo "=== FrankMoCap 调试脚本 ==="

# 设置环境
export PYOPENGL_PLATFORM=osmesa
export MESA_GL_VERSION_OVERRIDE=3.3
export MESA_GLSL_VERSION_OVERRIDE=330
export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$CONDA_PREFIX/lib:$LD_LIBRARY_PATH

echo "1. 检查输入视频..."
ls -la ./test/py.mp4
file ./test/py.mp4

echo "2. 检查环境..."
echo "CUDA可用: $(python -c 'import torch; print(torch.cuda.is_available())')"
echo "GPU: $(python -c 'import torch; print(torch.cuda.get_device_name(0) if torch.cuda.is_available() else "No GPU")')"

echo "3. 清理输出目录..."
rm -rf mocap_output
mkdir -p mocap_output

echo "4. 运行FrankMoCap（前10帧）..."
xvfb-run -a -s "-screen 0 1024x768x24" python -m demo.demo_frankmocap \
    --input_path ./test/py.mp4 \
    --out_dir ./mocap_output \
    --save_pred_pkl \
    --save_mesh \
    --use_smplx \
    --no_display \
    --start_frame 0 \
    --end_frame 10 \
    --single_person

echo "5. 检查输出..."
echo "mocap目录内容:"
ls -la mocap_output/mocap/ 2>/dev/null || echo "mocap目录为空"
echo "rendered目录内容:"
ls -la mocap_output/rendered/ 2>/dev/null || echo "rendered目录为空"
echo "根目录内容:"
ls -la mocap_output/

echo "完成!"
EOF
